package com.example.exam.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author shishuqian
 * date 2021/4/26
 * time 21:34
 * 描述：创建的试卷
 **/
@Data
@Entity
@Table(name = "t_exam_paper")
@ApiModel(value = "用户创建的试卷对象")
public class ExamPaper implements Serializable {

    private static final long serialVersionUID = -8825338515529551565L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;                //试卷id

    @ApiModelProperty(value = "试卷名称",required = true,example = "第一次考试")
    private String title;               //试卷名称

    @ApiModelProperty(value = "试卷描述",required = false,example = "试卷的描述")
    private String description;       //试卷描述

    @ApiModelProperty(value = "试卷总分(千分制)",required = true,example = "1000")

      private Double score;  //试卷总分

    @ApiModelProperty(value = "题目数量",required = true,example = "10")
    private Integer questionCount;   //题目数量

    @ApiModelProperty(value = "建议时长(分钟)",required = false,example = "60")
    private Integer suggestTime;    //建议时长(分钟)

    @ApiModelProperty(value = "试卷开始时间",required = true,example = "2021-05-06")
    private Date startTime;          //试卷开始时间

    @ApiModelProperty(value = "试卷结束时间",required = true,example = "2021-05-07")
    private  Date endTime;          //试卷结束时间

    @ApiModelProperty(value = "试卷创建时间",required = true,example = "2021-05-05")
    private Date createTime;        //试卷创建时间

    @ApiModelProperty(value = "试卷创建人id",required = true,example = "57868534")
    private Integer createUserId;  //试卷创建人id

    //单向一(试卷)对多(问题)
    //在t_choice表中插入外键question_id
    //级联保存、更新、删除、刷新;延迟加载。当删除question，会级联删除该选择题下的所有选项
    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "exam_paper_id")
    @ApiModelProperty(value = "试卷包含的题目",required = true)
    private List<Question> questionList;  //试卷包含的题目

    @ApiModelProperty(value = "试卷是否被删除时间")
    private Boolean deleted;            //该试卷是否被删除

    private Boolean status;   //试卷状态：0未发布，1已发布

    private Boolean viewAfterSubmit;    //提交后是否允许查看

    private Boolean selectPeople;      //试卷是否指定人去做

}
